<!DOCTYPE html>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <head th:include="include :: header"></head>
</head>

<body class="gray-bg">
<div class="container-div">
    <div class="row">

        <div class="col-sm-12 search-collapse">
                <ul> <li><strong>应用名称：</strong> [[${appCode}]]  </li></ul>
        </div>
        <div class="col-sm-12 search-collapse">
            <ul> <li><strong>接口编码：</strong> [[${interfaceCode}]] </li></ul>
        </div>
        <div class="col-sm-12 search-collapse">
            <ul> <li><strong>方法参数<span style="color: red">（注意：目前不支持嵌套bean的参数展示，规则中支持嵌套bean的属性配置，系统建议使用第一层的属性作为key）</span>：</strong><pre>[[${parameter}]]</pre> </li></ul>
        </div>
        <div class="col-sm-12 search-collapse">

        </div>
        <div class="col-sm-12 search-collapse">
            <ul> <li><strong>服务节点：</strong>
            </li></ul>
            <ul> <li>
            <label th:each="node:${nodes}" class="check-box">
                <button type="button" class="btn btn-primary" data-container="body" data-toggle="popover" data-placement="right" data-content="这里是提示内容">
                    [[${node}]]
                </button>
            </label>
            </li></ul>
        </div>
        <!--功能按钮-->
        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()">
                <i class="fa fa-plus"></i> 添加
            </a>
        </div>
        <!--规则列表-->
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>

    <input type="hidden" id="appCode" name="appCode" th:value="*{appCode}">
    <input type="hidden" id="interfaceCode" name="interfaceCode" th:value="*{interfaceCode}">
    <input type="hidden" id="parameter" name="parameter" th:value="*{parameter}">

</div>
    <div th:include="include :: footer"></div>
    <script>
        var prefix = ctx+ "functionRule";
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add/"+encodeURIComponent($("#appCode").val())+"/"+encodeURIComponent($("#interfaceCode").val()),
                removeUrl: prefix + "/remove",
                modalName: "规则",
                search: false,
                showExport: true,
                columns: [{
                    radio: true
                },
                    {
                        field : 'id',
                        title : 'ID',
                        sortable: false
                    },
                    {
                        field : 'ruleCode',
                        title : '规则编码',
                        sortable: false
                    },
                    {
                        field : 'description',
                        title : '规则说明',
                        sortable: false
                    },
                    {
                        field : 'ruleKey',
                        title : 'KEY',
                        sortable: false
                    },
                    {
                        field : 'ruleValue',
                        title : '入参',
                        sortable: false
                    },  {
                        field : 'updateTime',
                        title : '更新时间',
                        sortable: false
                    },{
                        title: '操作',
                        align: 'center',
                        formatter: function(value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-warning btn-xs  href="#" onclick="edit(\'' + row.appCode + '\',\'' + row.interfaceCode + '\',\'' + row.id + '\')"><i class="fa fa-edit"></i>修改</a> ');
                            actions.push('<a class="btn btn-danger btn-xs  href="#" onclick="remove(\'' + row.appCode + '\',\'' + row.interfaceCode + '\',\'' + row.id + '\')"><i class="fa fa-edit"></i>删除</a> ');
                            return actions.join('');
                        }
                    }
                   ]
            };
            $.table.init(options);
        });
        function edit(appCode,interfaceCode,id){
            var url = prefix + "/edit/"+encodeURIComponent($("#appCode").val())+"/"+encodeURIComponent($("#interfaceCode").val())+"/"+id;
            $.modal.open("修改" + $.table._option.modalName, url);
        }
        function remove(appCode,interfaceCode,id){
            $.modal.confirm("确定删除该条" + $.table._option.modalName + "信息吗？", function() {
                var url = $.common.isEmpty(id) ? $.table._option.removeUrl : $.table._option.removeUrl.replace("{id}", id);
                var data = { "appCode": appCode ,"interfaceCode": interfaceCode ,"id": id };
                $.operate.submit(url, "post", "json", data);
            });
        }
    </script>
</body>

</html>
